package cn.tedu.lucky.draw.server.protrocol.po;

import com.fasterxml.jackson.annotation.JsonFormat;

import javax.persistence.*;
import java.time.LocalDateTime;

/**
 * 为了将Activity声明为JPA实体类，该类上方必须添加@Entity注解
 * name是可选的，如果没有提供name属性，则默认使用类名作为实体类名称
 */
@Entity(name = "draw_activity")
public class Activity {
    /**
     * @Id 用于指定实体类中的某个字段作为数据库表的主键列
     * 以便于JPA提供者能够在数据库中准确追踪和管理每个记录
     *
     * @GeneratedValue用来指定主键生成策略,比如说使用数据库自身的自动增长策略
     * GenerationType.IDENTITY意味着数据库会在新插入数据时自动为id字段赋唯一值
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String name;

    private String description;

    private String img;
    /**
     *   @Column定义实体类属性到数据库表列的映射
     *   注解可以不加
     */
    @Column(name = "start_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;

    private Integer status;

    private LocalDateTime createTime;

    private LocalDateTime updateTime;

    private Integer sort;

    public Activity() {
    }

    public Activity(Long id, String name, String description, String img, LocalDateTime startTime, LocalDateTime endTime, Integer status, LocalDateTime createTime, LocalDateTime updateTime, Integer sort) {
        this.id = id;
        this.name = name;
        this.description = description;
        this.img = img;
        this.startTime = startTime;
        this.endTime = endTime;
        this.status = status;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.sort = sort;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }

    public LocalDateTime getStartTime() {
        return startTime;
    }

    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }

    public LocalDateTime getEndTime() {
        return endTime;
    }

    public void setEndTime(LocalDateTime endTime) {
        this.endTime = endTime;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    @Override
    public String toString() {
        return "Activity{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", description='" + description + '\'' +
                ", img='" + img + '\'' +
                ", startTime=" + startTime +
                ", endTime=" + endTime +
                ", status=" + status +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", sort=" + sort +
                '}';
    }
}
